package com.weds.edwx .service;

import com.weds.core.utils.DateUtils;
import com.weds.edwx.entity.TempMonitorEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.text.ParseException;
import java.util.List;

import com.weds.core.base.BaseService;
import com.weds.edwx.mapper .WarnSendUserMapper;
import com.weds.edwx.entity .WarnSendUserEntity;

/**
 * @Author sxm
 * @Description WarnSendUser管理
 * @Date 2020-02-22
 */
@Service
public class WarnSendUserService extends BaseService {

	@Autowired
	private WarnSendUserMapper warnSendUserMapper;

	private Logger log = LogManager.getLogger();

	public int deleteByPrimaryKey(Long xh) {
		return warnSendUserMapper.deleteByPrimaryKey(xh);
	}

	public int insert(WarnSendUserEntity record) {
		return warnSendUserMapper.insert(record);
	}

	public int insertSelective(WarnSendUserEntity record) {
		return warnSendUserMapper.insertSelective(record);
	}

	public WarnSendUserEntity selectByPrimaryKey(Long xh) {
		return warnSendUserMapper.selectByPrimaryKey(xh);
	}


	public int updateByPrimaryKeySelective(WarnSendUserEntity record) {
		return warnSendUserMapper.updateByPrimaryKeySelective(record);
	}

	public int updateByPrimaryKey(WarnSendUserEntity record) {
		return warnSendUserMapper.updateByPrimaryKey(record);
	}

	public List<WarnSendUserEntity> selectListByEntity(WarnSendUserEntity record) {
		return warnSendUserMapper.selectListByEntity(record);
	}

	public List<TempMonitorEntity> getWarnHealthInfoList(WarnSendUserEntity record) throws ParseException {
		record.setKssj(DateUtils.parseDate(record.getCtDate() + " 00:00:00", DateUtils.DATE_TIME_FORMAT));
		record.setJssj(DateUtils.addDays(DateUtils.parseDate(record.getCtDate() + " 00:00:00", DateUtils.DATE_TIME_FORMAT),1));
		return warnSendUserMapper.getWarnHealthInfoList(record);
	}

	public TempMonitorEntity selectWarnHealthInfo(TempMonitorEntity record){
		if(record.getUserLx()==0){
			return warnSendUserMapper.selectWarnHealthInfoInSide(record);
		}
		return warnSendUserMapper.selectWarnHealthInfoOutSide(record);
	}

	public int updateWarnHealthInfo(TempMonitorEntity record){
		if(record.getUserLx() == 0){
			return warnSendUserMapper.updateWarnHealthInfoInSide(record);
		}
		return warnSendUserMapper.updateWarnHealthInfoOutSide(record);
	}
	
	

	public int deleteBatchByKeys(List<WarnSendUserEntity> list) {
        return warnSendUserMapper.deleteBatchByKeys(list);
    }
    
    public int insertBatch(List<WarnSendUserEntity> list) {
		return warnSendUserMapper.insertBatch(list);
	}
	}
